import cv2
import DetectBoard.DetectBoard as DB

# 打开摄像头
cap = cv2.VideoCapture(0)  # 0 是默认摄像头的索引

while True:
    # 从摄像头捕获一帧
    ret, frame = cap.read()

    if not ret:
        print("无法读取摄像头")
        break

    # 处理捕获的图像
    output_image, coordinates = DB.process_tic_tac_toe_board(frame)

    # 显示处理后的图像
    cv2.imshow("Processed Image", output_image)
    print("Valid center coordinates:", coordinates)

    # 按 'q' 键退出
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

# 释放摄像头和窗口
cap.release()
cv2.destroyAllWindows()
